<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exerc&iacute;cio 2 - Imprimir divisores de um dado valor</title>
</head>
<body>
<%!
	String obterDivisores(String valorStr){
		String divisores = "(";
		int valorInt = Integer.parseInt(valorStr);
		for(int i = 1 ; i < (valorInt+1) ; i++){
			if(valorInt % i == 0){
				divisores += i;
				if(i < valorInt){
					divisores += ", ";
				}
			}
		}
		divisores += ")";
		
		return divisores;
	}
%>
<p>Os divisores de <%= request.getParameter("valor") %> 
	são: <%= obterDivisores(request.getParameter("valor")) %></p>
</body>
</html>